﻿var resultElement;
var findButton;
var cancelButton;

function pageLoad() {
    resultElement = $get("results");
    findButton = $get("buttonFind");
    cancelButton = $get("buttonCancel");
    var viewer = $find("pdfViewer");
    viewer.add_searching(onSearch);
    viewer.add_searchCompleted(onSearchCompleted);
}

function onSearch(sender, args) {
    _updateButtons(true);    
}

function onSearchCompleted(sender, args) {
    _updateButtons(false);
}

function _updateButtons(pending) {
    cancelButton.disabled = pending ? '' : 'disabled';
    findButton.disabled = pending ? 'disabled' : '';
}

if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();